package com.settlement.system.service.impl;

import com.settlement.system.mapper.BaseMapper;
import com.settlement.system.mapper.TblAcsUserRoleAuthorityMapper;
import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.model.entity.common.SinglePage;
import com.settlement.system.model.entity.common.TblAcsUserRoleAuthority;
import com.settlement.system.service.ITblAcsUserRoleAuthorityService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import jakarta.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * ACS用户角色权限 服务实现类
 * @author Ximi
 * @since 2020-06-05
 */
@Service
public class TblAcsUserRoleAuthorityServiceImpl extends BaseServiceImpl implements ITblAcsUserRoleAuthorityService {

    @Resource
    private TblAcsUserRoleAuthorityMapper tblAcsUserRoleAuthorityMapper;

    @Override
    public BaseMapper init() {
        return tblAcsUserRoleAuthorityMapper;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = ServiceException.class)
    public void addAllDetail(List<TblAcsUserRoleAuthority> dates) throws ServiceException {
        try{
            for(TblAcsUserRoleAuthority item :dates){
                this.tblAcsUserRoleAuthorityMapper.insert(item);
            }
        }catch (Exception e) {
            throw new ServiceException(e);
        }
    }

    @Override
    public List<TblAcsUserRoleAuthority> searchDetailList(SinglePage singlePage, Map<String, Object> model, String orderByField, String orderBy) throws ServiceException {

        try {
            return tblAcsUserRoleAuthorityMapper.searchDetailList(singlePage,model,orderByField,orderBy);
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }

    @Override
    public List<TblAcsUserRoleAuthority> selctAllUserInfo(Map<String, Object> params) throws ServiceException {
        try {
            return tblAcsUserRoleAuthorityMapper.selctAllUserInfo(params);
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }

    @Override
    public List<TblAcsUserRoleAuthority> selctAllUserByBillNo(Map<String, Object> params) throws ServiceException {
        try {
            return tblAcsUserRoleAuthorityMapper.selctAllUserByBillNo(params);
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }

}

